package com.cq.digitalemployee.user.service.impl;

import com.cq.digitalemployee.user.dao.SysRoleDao;
import com.cq.digitalemployee.user.entity.po.SysRole;
import com.cq.digitalemployee.user.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;

/**
 *
 * 角色操作接口实现
 *
 * @author zzz
 */
@Service
public class RoleServiceImpl implements RoleService {

    @Autowired
    SysRoleDao sysRoleDao;


    @Override
    public Set<SysRole> findByUser(String userId) {
        return sysRoleDao.findByUser(userId);
    }

    @Override
    public int add(SysRole sysRole) {
        return sysRoleDao.insertSelective(sysRole);
    }

    @Override
    public int update(SysRole sysRole) {
        return sysRoleDao.updateByPrimaryKeySelective(sysRole);
    }

    @Override
    public int delete(String id) {
        return sysRoleDao.deleteByPrimaryKey(id);
    }

    @Override
    public List<SysRole> findAll() {
        return sysRoleDao.findAll();
    }

    @Override
    public SysRole findById(String id) {
        return sysRoleDao.selectByPrimaryKey(id);
    }

    @Override
    public int grantByUser(String roleId, String userId) {
        return sysRoleDao.grantByUser(roleId, userId);
    }
}
